home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 2 / Meeting Pearls Vol. II (1995)(GTI - Schatztruhe)[!].iso / Pearls / dev / Oberon4Amiga / Dialogs / Dialogs.Text (.txt) < prev    next >
Oberon Text  |  1994-11-28  |  20KB  |  351 lines

  1. Syntax10.Scn.Fnt
  2. ParcElems
  3. Alloc
  4. Syntax20.Scn.Fnt
  5. Syntax14.Scn.Fnt
  6. Syntax12.Scn.Fnt
  7. Syntax14b.Scn.Fnt
  8. Chicago12.Scn.Fnt
  9. DialogElems
  10. Alloc
  11. DialogStaticTexts
  12. ItemDesc
  13. Syntax12b.Scn.Fnt
  14. ComboBox 
  15. DialogStaticTexts
  16. ItemDesc
  17. Syntax12b.Scn.Fnt
  18. Text 
  19. DialogComboBoxes
  20. ItemDesc
  21. mhk28
  22. DialogStaticTexts
  23. ItemDesc
  24. Syntax12b.Scn.Fnt
  25. AnalogClock 
  26. DialogAnalogClocks
  27. ItemDesc
  28. DialogStaticTexts
  29. ItemDesc
  30. Syntax12b.Scn.Fnt
  31. Clock 
  32. DialogClocks
  33. ItemDesc
  34. DialogStaticTexts
  35. ItemDesc
  36. Syntax12b.Scn.Fnt
  37. Date 
  38. DialogDates
  39. ItemDesc
  40. DialogStaticTexts
  41. ItemDesc
  42. Syntax12b.Scn.Fnt
  43. ColorPicker 
  44. DialogColorPickers
  45. ItemDesc
  46. DialogStaticTexts
  47. ItemDesc
  48. Syntax12b.Scn.Fnt
  49. IntegerSlider 
  50. DialogStaticTexts
  51. ItemDesc
  52. Syntax12b.Scn.Fnt
  53. Line 
  54. DialogLines
  55. ItemDesc
  56. DialogStaticTexts
  57. ItemDesc
  58. Syntax12b.Scn.Fnt
  59. Circle 
  60. DialogCircles
  61. ItemDesc
  62. DialogStaticTexts
  63. ItemDesc
  64. Syntax12b.Scn.Fnt
  65. Rectangle 
  66. DialogRectangles
  67. ItemDesc
  68. DialogStaticTexts
  69. ItemDesc
  70. Syntax12b.Scn.Fnt
  71. Sliders 
  72. DialogSliders
  73. ItemDesc
  74. DialogIntegerSliders
  75. ItemDesc
  76. DialogSliders
  77. ItemDesc
  78. DialogStaticTexts
  79. ItemDesc
  80. staticTextRadios
  81. Syntax12b.Scn.Fnt
  82. Radio Buttons
  83. DialogTexts
  84. ItemDesc
  85. DialogRadioButtons
  86. ItemDesc
  87. DialogRadioButtons
  88. ItemDesc
  89. radio2
  90. DialogRadioButtons
  91. ItemDesc
  92. DialogGroupBoxes
  93. ItemDesc
  94. radio3
  95. Syntax12b.Scn.Fnt
  96. GroupBox
  97. DialogStaticTexts
  98. ItemDesc
  99. staticTextCheckBox
  100. Syntax12b.Scn.Fnt
  101. CheckBox 
  102. DialogCheckBoxes
  103. ItemDesc
  104. checkbox
  105. DialogButtons
  106. ItemDesc
  107. Button
  108. Syntax12b.Scn.Fnt
  109. Syntax12i.Scn.Fnt
  110. Syntax12b.Scn.Fnt
  111. DialogLines
  112. ItemDesc
  113. DialogStaticTexts
  114. ItemDesc
  115. Syntax12b.Scn.Fnt
  116. DialogTexts
  117. ItemDesc
  118. DialogTexts
  119. ItemDesc
  120. DialogStaticTexts
  121. ItemDesc
  122. Syntax12b.Scn.Fnt
  123. DialogButtons
  124. ItemDesc
  125. Dialog.Open
  126. fileName
  127. Syntax10b.Scn.Fnt
  128. DialogButtons
  129. ItemDesc
  130. Dialog.Edit
  131. fileName
  132. Syntax10b.Scn.Fnt
  133. DialogStaticTexts
  134. ItemDesc
  135. Syntax12b.Scn.Fnt
  136. Dialog
  137. DialogTexts
  138. ItemDesc
  139. fileName
  140. DialogListBoxes
  141. ItemDesc
  142. DialogInsert.Do
  143. DialogStaticTexts
  144. ItemDesc
  145. Syntax12b.Scn.Fnt
  146. DialogStaticTexts
  147. ItemDesc
  148. temp43
  149. Syntax12b.Scn.Fnt
  150. DialogStaticTexts
  151. ItemDesc
  152. temp26
  153. Syntax12b.Scn.Fnt
  154. DialogStaticTexts
  155. ItemDesc
  156. Syntax12b.Scn.Fnt
  157. DialogStaticTexts
  158. ItemDesc
  159. Syntax12b.Scn.Fnt
  160. DialogTexts
  161. ItemDesc
  162. DialogTexts
  163. ItemDesc
  164. DialogTexts
  165. ItemDesc
  166. DialogTexts
  167. ItemDesc
  168. DialogTexts
  169. ItemDesc
  170. DialogInsert.Open
  171. DialogButtons
  172. ItemDesc
  173. System.Time
  174. Syntax10b.Scn.Fnt
  175. DialogButtons
  176. ItemDesc
  177. MyEdit.Print
  178. Syntax10b.Scn.Fnt
  179. DialogStaticTexts
  180. ItemDesc
  181. Syntax10b.Scn.Fnt
  182. DialogTexts
  183. ItemDesc
  184. DialogButtons
  185. ItemDesc
  186. Print
  187. MyEdit.Print
  188. Syntax10b.Scn.Fnt
  189. DialogStaticTexts
  190. ItemDesc
  191. Draft
  192. Syntax10b.Scn.Fnt
  193. draft
  194. DialogCheckBoxes
  195. ItemDesc
  196. draft
  197. DialogStaticTexts
  198. ItemDesc
  199. Syntax10b.Scn.Fnt
  200. DialogTexts
  201. ItemDesc
  202.     Chicago10.Scn.Fnt
  203. Syntax10b.Scn.Fnt
  204. Syntax10i.Scn.Fnt
  205. A Guide to Dialogs
  206. A Graphical User Interface for Oberon
  207. M. Knasm
  208. ller, 12.8.94 / 8.11.94
  209. 1. Introduction
  210. Graphical user interfaces of modern workstations are usually composed of a number of items such as buttons, check boxes, text fields and scroll bars which allow a user to interactively communicate with the computer. We call a panel of such items a dialog.
  211. This guide describes the use of dialogs in the Oberon System. Dialogs extend the original user interface of Oberon and give the user a choice between a compact textual interface (for professional programmers) and a more intuitive graphical interface (for end users).
  212. A similar package for graphical user interfaces is the Gadgets system implemented for Oberon System 3. While the Gadgets system is more powerful (e.g. nested objects) it is also more complicated and incompatible with the standard Oberon system. The virtue of the Dialogs package is that it is extremly light-weight and smoothly fits into the existing Oberon system.
  213. Figure 1 shows a sample dialog. Dialogs can be edited interactively and stored on a file. Applications can use dialogs by loading them from a file and retrieving their items by name or by a number. Dialog items can also be connected to commands that are called automatically when the item is clicked. Thus it is very simple to add a graphical user interface to any Oberon program. 
  214. Figure 1. A sample dialog
  215. Module Dialog offers commands to use, edit and print a dialog. Dialogs can be displayed in two modes: Dialogs.Open opens a dialog for using it while Dialogs.Edit opens it for editing. 
  216. 2. Using Dialogs
  217. Opening a Dialog for Using its Items
  218. Dialog.Open (name | ^) opens a dialog viewer and displays the dialog from file name. The menu text of the opened viewer is taken from the file Dialog.Menu.Text if such a file exists.
  219. The user can now work with the dialog by clicking at buttons or check boxes or by typing text into a text field. He cannot modify the dialog, i. e., he cannot add or move dialog items. To do that he has to use the command Dialog.Edit. 
  220. Opening a Dialog for Editing
  221. Dialog.Edit (name | ^) opens a dialog viewer and displays the dialog from file name for editing. If such a file does not exist, a new dialog is created.
  222. The following sections describe how to build dialogs by inserting items, moving and resizing them, and inspecting and modifying their attributes. Most editing operations can be done by moving and clicking the mouse. Thus clicking the left button while editing a dialog, causes a cross to appear. This is called the caret.
  223. Inserting New Dialog Items
  224. Dialog items (buttons, check boxes, etc.) can be inserted in viewers opened with Dialog.Edit. Every dialog item is defined in a separate module that exports also a command Insert, to insert an item of this class in the panel containing the caret position. 
  225. The syntax of the Insert command is
  226.     <itemModule>.Insert ([name] [x y w h] | ^)
  227. where name is a panel-wide unique name, x and y are the lower left coordinates, w is the width and h is the heigth of the object. if these parameters are not set, standard values will be taken. Usually no item can overlap others.
  228. The following items are currently implemented:
  229. DialogButtons. A button is a small named rectangle that can be pushed with an mouse click. 
  230. DialogCheckBoxes. A check box is a rectangular button that can be in two states, on and off, toggled with a mouse click. Usally there is a static text displayed to its right. 
  231. DialogStaticTexts. A static text item is a text that is shown in a panel but cannot be edited.
  232. DialogTexts. A text item is a rectangle in which the user can enter text.
  233. DialogGroupBoxes. A group box groups together several objects. Of course a group box may overlap other elements.
  234. DialogRadioButtons. A radio button is a diamond object with a state that can be on or off. All radio buttons within a group box are related and represent mutually exclusive choices (i.e., only one button of this set is on at any time).
  235. DialogListBoxes. A list box displays a text of lines, that can be selected by moving the mouse up and down.
  236. DialogComboBoxes. A combo box is an item containing an entry field and a push button. It responds to a mouse click on the push button by showing a text of lines that can be selected by moving the mouse up and down.
  237. DialogSliders. A slider item consists of a rectangular area with a small bar inside. It is used to enter integer numbers.
  238. DialogIntegerSliders. An integer slider item consists of a rectangular area with an integer number inside.
  239. DialogLines. A line item is a graphical object, which can be used to draw a line in the panel.
  240. DialogCircles. A circular item which may overlap other elements.
  241. DialogRectangles. A rectangular item which may overlap other elements.
  242. DialogDates. A date item displays the current date.
  243. DialogClocks. A (digital) clock is an item displaying the current time.
  244. DialogAnalogClock. An analog clock displaying the current time.
  245. DialogColorPicker. A color picker item is a rectangular item, which allows the user to select on of the sixteen Oberon colors.
  246. DialogGraphics. Graphic items support incorporation of graphs compatible with the standard Draw package into dialogs.
  247. Items can also be created using the dialog "Insert.Dlg", which can be opened with Dialog.Open Insert.Dlg (see Figure 2). 
  248. Figure 2. Insert.Dlg
  249. Selecting an item of the list box inserts a new item in the panel containing the caret. There are also several text items which allow the user to specify parameters for the new items. If these parameters are not set, default values will be taken.
  250. The meaning of the text items are as follow:
  251.     Name the panel-wide unique name of the item.
  252.     X, Y the lower left corner coordinates of the item in panel-relative coordinates.
  253.     W the width of the item.
  254.     H the height of the item.
  255.     Cmd a command which is called whenever a property of the object is changed.
  256.     Par a string containing the names of the text items that should be concatenated to form Oberon.Par.Text. 
  257. Cmd and Par are associated by following rule: The command cmd can assume that Oberon.Par.text contains the texts defined through the property par (e.g. if par = "t1 t2" and there is a text item t1 containing the text "name" and also a text item t2 containing the text "text", then the command can assume that Oberon.Par.text contains the text "name text").
  258. Example: To create a dialog that allows you to invoke System.Time via a button you have to do the following:
  259. -    type "MyDialog" in the Dialog field and click the "Edit" Button.
  260. -    set the caret in the new viewer with a left mouse click.
  261. -    type "Time" in the Name field and "System.Time" in the Cmd field.
  262. -    select "Button" from the list box.
  263. This will make the following dialog (see Figure 3).
  264. Figure 3. MyDialog
  265. -    store it on a file with the command Dialog.Store.
  266. -    open it again clicking the "Open" button.
  267. -    every click at the "Time" button will now invoke the command System.Time. 
  268. Mouse Clicks
  269. ML sets the caret to the position of the mouse pointer.
  270. MR selects all dialog items in the rectangle described with the pressed mouse button.
  271. MM moves the selected elements (or the element under the mouse pointer if no element is selected) while the mouse is moved.
  272. MR + ML deletes the selected items.
  273. MR + MM copies the selected object to the position of the mouse pointer.
  274. MM + ML changes the size of the element under the mouse pointer, while the mouse is moved.
  275. MM + MR opens a dialog to edit the properties of the object under the mouse pointer.
  276. ML + MM copies the selected objects to the mouse pointer.
  277. Storing a Dialog on a File
  278. Dialog.Store stores the dialog under the name appearing in its menu frame.
  279. Printing a Dialog
  280. Dialog.Print server  (* | ^ | {name} ~) prints dialogs to a print server named server. If "*" is specified, the dialog in the marked viewer is printed. Otherwise the dialogs specified by the names are printed.
  281. 3. Inspecting and Modifying the Attributes of an Item
  282. The attributes of an item can be conveniently inspected and modified by doing an MM+MR click on the item. A new dialog will appear that allows changing the attributes of the inspected item. Alternatively the user may also inspect and modify these attributes using the following commands.
  283. Retrieving Attributes
  284. Dialog.GetInitCmd writes the command of the marked dialog to the log viewer. This cmd will be called by open the dialog with Dialog.Open. It can be used to initaly different items.
  285. Dialog.GetCmd writes the command of the object under the caret to the log viewer.
  286. Dialog.GetPar writes the parameter of the object under the caret to the log viewer.
  287. Dialog.GetDim writes the coordinates of the lower left corner, the width and the height of the object under the caret to the log viewer
  288. Dialog.GetName writes the name of the object under the caret to the log viewer.
  289. Changing the Attributes of an Item
  290. Dialog.SetInitCmd (cmd | ^) sets the command of the marked dialog to cmd.
  291. Dialog.SetCmd (cmd | ^) sets the command of the object under the caret to cmd.
  292. DialogSetPar (par | ^) sets the parameter of the object under the caret to par.
  293. Dialog.SetDim (x y w h | ^) sets the lower left corner coordinates of the object under the caret to x and y, the width to w, and the height to h. 
  294. Dialog.SetName (name | ^) sets the name of the object under the caret to name.
  295. Dialog.AlignSelected (dir | ^) aligns the selected objects so that they have the same left, right, top or bottom coordinates (specified by dir = R(ight), L(eft), U(p) or D(own)).
  296. Dialog.RegulateDistance (dir | ^) regulates the distance between the selected objects.
  297. Dialog.SetGrid (int| ^) sets the grid to which mouse movements are restricted.
  298. 4. A very simple Dialog
  299. Dialogs can be used as a graphical user interface for existing Oberon applications. This is shown in Fig. 4. Lets assume a dialog "Open.Dlg" that contains a text named "file" and a button named "Open". The button is associated with the command Edit.Open. The button property par (see above) is set to "file".
  300. Figure 4. Open.Dlg.
  301. The user can open the dialog with Dialog.Open Open.Dlg and can write a file-name in the text item. Pressing the "Open"-button opens the specified file.
  302. 5. Retrieving Dialog Items from a Program
  303. Dialog items can be retrieved by name. A dialog panel p can be opened by DialogFrames.OpenPanel(..., p). The item with the name "n" can then be retrieved with item : = p.NamedObject ("n").
  304. The following example shows how to use dialogs from a program. Lets assume a dialog "Test.Dlg" (see Fig. 5) that contains a text named "file", a check box named "draft", and a button named "Do". The button is associated with a command MyEdit.Print. Thus clicking the button calls this command which prints the file specified by the "file" in the mode specified by the check box "draft" (draft mode or normal mode). 
  305. Figure 5. Test.Dlg
  306. The source code of MyEdit could be as follows:
  307. MODULE MyEdit;
  308.     IMPORT DialogCheckBoxes, DialogFrames, Dialogs, DialogTexts, Oberon, TextFrames, Texts;
  309.     VAR  w: Texts.Writer; 
  310.     PROCEDURE Open*;
  311.     (** you can also use Dialog.Open Test.Dlg instead of this command *)
  312.         VAR x, y: INTEGER; p: Dialogs.Panel;
  313.     BEGIN
  314.         Oberon.AllocateUserViewer (Oberon.Mouse.X, x, y);
  315.         DialogFrames.OpenPanel ("Test.Dlg", x, y, p);
  316.     END Open;
  317.     PROCEDURE Print*;
  318.     (** prints the text in draft or not draft mode *)
  319.         VAR t, draft: Dialogs.Object; par: Oberon.ParList; res: INTEGER; t1: Texts.Text; p: Dialogs.Panel;
  320.     BEGIN
  321.         NEW (par); par.text := TextFrames.Text (""); 
  322.         par.vwr := Oberon.FocusViewer; par.frame := Oberon.Par.frame;
  323.         p := Dialogs.cmdPanel; (*the panel from where the command was called*)
  324.         t := p.NamedObject ("file"); 
  325.         draft := p.NamedObject ("draft");
  326.         WITH t: DialogTexts.Item DO
  327.             WITH draft: DialogCheckBoxes.Item DO
  328.                 IF draft.on THEN
  329.                     Texts.WriteString (w, "QuickDraw % ");
  330.                 ELSE
  331.                     Texts.WriteString (w, "QuickDraw ");
  332.                 END;
  333.                 t1 := t.GetText (); Texts.Save (t1, 0, t1.len, w.buf); Texts.Append (par.text, w.buf); 
  334.                 Oberon.Call ("Edit.Print", par, FALSE, res);
  335.             ELSE
  336.             END
  337.         ELSE
  338.         END
  339.     END Print;
  340. BEGIN
  341.     Texts.OpenWriter (w);
  342. END MyEdit.
  343. 6. Dialog Elements
  344. Dialogs can also be used as elements in a text (subclass of Texts.Element). The command DialogElems.Insert inserts a new dialog element into a text at the text caret position. Using the middle mouse button, a dialog element can be "opened" for editing in a dialog viewer. The command DialogElems.Update in the viewer
  345. s menu can be used to make the modifications in the dialog permanent. Dialog elements can be used like ordinary dialogs: focus the element using the left mouse key and do everything what you would do with an ordinary dialog.
  346. command    explicit parameters    implicit parameters
  347. DialogElems.Insert    ("^" | "*" | name)    caret (plus marked viewer, if "*" is used)
  348. Inserts a dialog element sized to show the dialog stored in file "name". If a dialog viewer is marked, the command inserts the dialog of this viewer.
  349. Comments
  350. Error reports and comments may be sent to knasmueller@ssw.uni-linz.ac.at or oberon@ssw.uni-linz.ac.at
  351.